package cc.wenshixin.basic;

import javax.swing.*;

public class MenuBarComponentTest {
    private static final int WIDTH = 300;
    private static final int HEIGHT = 200;

    public static void main(String[] args) {
        JFrame jf = new JFrame();
        jf.setSize(WIDTH, HEIGHT);
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jf.setTitle("学生管理系统");

        JMenuBar menuBar = new JMenuBar();
        jf.setJMenuBar(menuBar);
        JMenu menuFile = new JMenu("文件");
        JMenu menuEdit = new JMenu("编辑");
        JMenu menuView = new JMenu("视图");
        menuBar.add(menuFile);
        menuBar.add(menuEdit);
        menuBar.add(menuView);

        JMenuItem itemOpen = new JMenuItem("打开");
        JMenuItem itemSave = new JMenuItem("保存");
        JMenuItem  itemPrint = new JMenuItem("打印");
        JMenuItem itemQuit = new JMenuItem("退出");

        menuFile.add(itemOpen);
        menuFile.add(itemSave);
        menuFile.addSeparator();
        menuFile.add(itemPrint);
        menuFile.add(itemQuit);

        JPanel contentPane = new JPanel();
        jf.setContentPane(contentPane);
        JButton btnTest = new JButton("这是一个测试按钮组件");
        contentPane.add(btnTest);

        jf.setVisible(true);
    }
}
